#include "GfxD3D9.h"

using namespace imGraphics;

void D3D9Renderer::SetWorldMatrix(Matrix &NewWorld) {
	m_World = NewWorld;
	m_D3DWorld = m_World;
}

void D3D9Renderer::SetViewMatrix(Matrix &NewView) {
	m_View = NewView;
	m_D3DView = m_View;

	m_D3DVP = m_D3DView * m_D3DProjection;
}

void D3D9Renderer::SetProjectionMatrix(Matrix &NewProjection) {
	m_Projection = NewProjection;
	m_D3DProjection = m_Projection;

	m_D3DVP = m_D3DView * m_D3DProjection;
}

void D3D9Renderer::StartFrame() {
	pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER , D3DCOLOR_XRGB( 32,160,224 ), 1.0f, 0 );
	pd3dDevice->BeginScene();
	return;
}

void D3D9Renderer::EndFrame() {
	pd3dDevice->EndScene();
	pd3dDevice->Present(NULL, NULL, NULL, NULL);
	return;
}

iMeshDriver* D3D9Renderer::GetMeshDriver() {
	return new D3D9MeshDriver();
}

iRenderTarget* D3D9Renderer::GetNewRenderTarget() {
	return NULL;
}

iShader* D3D9Renderer::GetNewShader() {
	return new D3D9Shader();
}

iTexture* D3D9Renderer::GetNewTexture() {
	return new D3D9Texture();
}